package com.zcx.pojo.vo;

import java.util.HashMap;
import java.util.Map;

public class JSONResult {

    private Map<String, Object> result = new HashMap<>();

    public JSONResult put(String key, Object value) {
        result.put(key, value);
        return this;
    }

    public JSONResult() {
    }

    public JSONResult ok() {
        result.put("status", 200);
        return this;
    }

    public JSONResult ok(String msg) {
        result.put("status", 200);
        result.put("msg", msg);
        return this;
    }

    public JSONResult error() {
        result.put("status", 500);
        return this;
    }

    public JSONResult error(String msg) {
        result.put("status", 500);
        result.put("msg", msg);
        return this;
    }

    public Map<String, Object> getResult() {
        return result;
    }

    @Override
    public String toString() {
        return this.result.toString();
    }
}
